home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_08_08
/
8n08049a
< prev
next >
Wrap
Text File
|
1990-07-17
|
1KB
|
57 lines
// meal1.cxx - first attempt at OOP design
#include <stream.h>
enum ENTREE {SteakPlatter,Fish};
enum DESSERT {Pie,Cake,Jello};
enum APPETIZER {Melon,ShrimpCocktail};
class Dessert
{
int kind;
public:
Dessert(int what=Pie) { kind = what;}
cost();
};
class Entree
{
int kind;
public:
Entree(int what=SteakPlatter) { kind = what;}
cost();
};
class Appetizer
{
int kind;
public:
Appetizer(int what=Melon) { kind = what;}
cost();
};
class Meal
{
Appetizer a;
Entree e;
Dessert d;
public:
Meal(APPETIZER=Melon,ENTREE=Fish,DESSERT=Jello);
cost();
};
//-------------------------------------------
// class member function definitions
int Meal::cost() {return 1;}
Meal::Meal(APPETIZER aval,ENTREE eval,DESSERT dval)
: a(aval),e(eval),d(dval) { }
//--------------------------------------------
main()
{
Meal m(Melon,Fish,Jello);
printf("Price %d\n",m.cost());
}